<admintpl file="header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">分类列表</a></li>
        <!--<li><a href="{:U('add')}">新增分类</a></li>-->
    </ul>
    <form class="well form-search" method="post" action="{:U('lists')}">
        分类名称：
        <input type="text" name="cate_name" style="width: 120px;" value="{$formget.cate_name}" placeholder="">
        <!--热门：
        <select name="if_hot" id="">
            <option value="">全部</option>
            <option value="yes" <if condition="$formget.if_hot eq 'yes'">selected</if> >推荐</option>
            <option value="no" <if condition="$formget.if_hot eq 'no'">selected</if> >非推荐</option>
        </select>-->
        <input type="submit" style="margin-left: 5px;" class="btn btn-primary" value="搜索"/>
    </form>

    <a data-toggle="modal" data-target="#myModal"  class="btn btn-primary" >添加</a>

    <table style="margin-top: 10px;word-break:break-all;" class="table table-hover table-bordered table-list"
           id="menus-table">
        <thead>
        <tr>
            <th>序号</th>
            <th>排序</th>
            <th>名称</th>
            <!--<th>图标</th>
            <th>推荐</th>-->
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
            <volist name="list" id="vo" key="k">
                <tr>
                    <td>{$k}</td>
                    <td>{$vo.sort}</td>
                    <td>{$vo.cate_name}</td>
                    <!--<td><img title="点击查看原图" name="{$vo.cover_photo|setUrl}" src="{$vo.cover_photo|setUrl}?imageView2/2/h/30" onclick="parent.image_preview_dialog(this.name);"></td>
                    <td>
                        <if condition="$vo['if_hot'] eq 'yes'">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name="if_hot"   id={$vo.cate_id} checked value="no"/>推荐
                                </label>
                            </div>
                        <else />
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name="if_hot"   id="{$vo.cate_id}"  value="yes"/>推荐
                                </label>
                            </div>
                        </if>
                    </td>-->
                    <td><a data-toggle="modal" data-target="#myModal_2" name="{$vo.cate_name}" sort="{$vo.sort}" tid="{$vo.cate_id}" class="add_ext" >编辑</a> | <a class="js-ajax-delete" href="{:U('del', ['cate_id' => $vo['cate_id']])}">删除</a></td>
                </tr>
            </volist>
        </tbody>
    </table>
    <div class="pagination">{$Page}</div>
</div>
<div>
    <!--添加-->
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">添加分类</h3>
        </div>
        <form action="{:U('add')}" method="post"
              class="form-horizontal js-ajax-form">
            <div class="modal-body">
                <table>
                    <tbody>
                    <tr>
                        <td>名称：</td>
                        <td><input type="text" name="cate_name" class="" value=""></td>
                        <td><div id="username_msg"></div></td>
                    </tr>
                    <tr>
                        <td>排序：</td>
                        <td><input type="text" name="sort" value=""><span>&nbsp;*</span></td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                <button type="submit" class="btn btn-primary ">保存</button>
            </div>
        </form>
    </div>

    <!--编辑-->
    <div id="myModal_2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">编辑分类</h3>
        </div>
        <form action="{:U('edit')}" method="post"
              class="form-horizontal js-ajax-form">
            <div class="modal-body">
                <table>
                    <tbody>
                    <tr>
                        <td>分类名称：</td>
                        <input type="hidden" name="cate_id" class="id" value="">
                        <td><input type="text" name="cate_name" id="name" class="" value=""></td>
                    </tr>
                    <tr>
                        <td>排序：</td>
                        <td><input type="text" name="sort" id="sort" value=""><span>&nbsp;*</span></td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                <button type="submit" class="btn btn-primary ">保存</button>
            </div>
        </form>
    </div>



    <script src="__PUBLIC__/js/common.js"></script>
    <script>
        $(".hidden").hide();
        $('.add_ext').click(function () {
            var name = $(this).attr("name");
            var id = $(this).attr("tid");
            var sort = $(this).attr("sort");

            $(".id").val(id);
            // $("#id").val(id);
            $("#name").val(name);
            $("#sort").val (sort);
        });

    </script>
</body>
</html>